package com.aaa.service.impl;

import com.aaa.dao.UserInfoDao;
import com.aaa.dao.impl.UserInfoDaoImpl;
import com.aaa.service.UserInfoService;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2021/7/15 9:42
 * @description：用户业务实现类
 * @modified By：
 * @version: 1.0
 */
public class UserInfoServiceImpl  implements UserInfoService {
    UserInfoDao userInfoDao = new UserInfoDaoImpl();
    @Override
    public boolean addUser(Map map) {
        map.put("createtime",new Date());
        return userInfoDao.addUser(map);
    }

    @Override
    public boolean deleteUserById(int id) {
        return userInfoDao.deleteUserById(id);
    }

    @Override
    public boolean deleteUserBatch(String ids) {
        return userInfoDao.deleteUserBatch(ids);
    }

    @Override
    public boolean updateUser(Map map) {
        map.put("createtime",new Date());
        return userInfoDao.updateUser(map);
    }

    @Override
    public List<Map<String, Object>> findAllUser() {
        return userInfoDao.findAllUser();
    }

    @Override
    public Map<String, Object> findUserById(int id) {
        return userInfoDao.findUserById(id);
    }

    @Override
    public boolean findUserByUsername(String username) {
        return userInfoDao.findUserByUsername(username);
    }

    @Override
    public List<Map<String, Object>> findAllUserPage(Map map) {
        if(map.get("field")==null){
            //默认按照id的倒序排列
            map.put("field","id");
            map.put("order","desc");
        }
        return userInfoDao.findAllUserPage( map);
    }
    /**
     * @create by: Teacher陈（86521760@qq.com）
     * @description:获取总条数
     * @create time: 2021/7/16 14:52
     * @param
     * @return int
     */
    @Override
    public int getCount(Map map) {
        return userInfoDao.getCount(map);
    }
}
